import {
  FrontPageParams,
  StandardizePageParams,
  StdPageParams,
  StdPageResult,
  StdResponse,
} from '/@/api/model/baseModel';
import { defHttp } from '/@/utils/http/axios';
import { MethodsList, Setting } from '/@/api/monitor/entity/entity';

export function listSettings(params: FrontPageParams | StdPageParams) {
  return defHttp.get<StdPageResult<Setting>>({
    url: '/monitor/settings',
    params: StandardizePageParams(params),
  });
}

export function deleteSetting(id: number) {
  return defHttp.delete<StdResponse>({
    url: `/monitor/setting/${id}`,
  });
}

export function getSetting(id: number) {
  return defHttp.get<Setting>({
    url: `/monitor/setting/${id}`,
  });
}

export function getMethods() {
  return defHttp.get<MethodsList>({
    url: `/monitor/setting/methods`,
  });
}

export function editSetting(st: Setting) {
  return defHttp.put<StdResponse>({
    url: `/monitor/setting`,
    data: st,
  });
}

export function addSetting(st: Setting) {
  return defHttp.post<StdResponse>({
    url: `/monitor/setting`,
    data: st,
  });
}
